package com.jiguangssp.addemo.act;

import androidx.constraintlayout.widget.ConstraintLayout;

import android.os.Bundle;

import com.jiguangssp.addemo.R;
import com.jiguangssp.addemo.util.Constants;

import xyz.adscope.amps.ad.interstitial.AMPSInterstitialAd;
import xyz.adscope.amps.ad.interstitial.AMPSInterstitialLoadEventListener;
import xyz.adscope.amps.common.AMPSError;
import xyz.adscope.amps.config.AMPSRequestParameters;

public class InterstitialActivity extends BaseAdActivity {

    ConstraintLayout constraintRoot;
    private AMPSInterstitialAd interstitialAd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_interstitial);
        constraintRoot = findViewById(R.id.constraint_act_interstitial_root);
        loadAd();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (interstitialAd != null) {
            interstitialAd.destroy();
            interstitialAd = null;
        }
    }

    @Override
    public void loadAd() {
        super.loadAd();
        AMPSRequestParameters parameter = new AMPSRequestParameters.Builder()
                .setSpaceId(Constants.JG_PUB_SPACE_ID_INTERSTITIAL)//插屏广告位Id
                .setTimeOut(Constants.JG_PUB_TIME_OUT)//超时时间
                .setWidth(600)//插屏广告宽度，单位px
                .setHeight(600)//插屏广告高度，单位px
                .build();
        interstitialAd = new AMPSInterstitialAd(this, parameter, new AMPSInterstitialLoadEventListener() {
            @Override
            public void onAmpsSkippedAd() {

            }

            @Override
            public void onAmpsAdLoaded() {
                interstitialAd.show(InterstitialActivity.this);
            }

            @Override
            public void onAmpsAdFailed(AMPSError ampsError) {

            }

            @Override
            public void onAmpsAdShow() {

            }

            @Override
            public void onAmpsAdClicked() {

            }

            @Override
            public void onAmpsAdDismiss() {

            }

            @Override
            public void onAmpsVideoPlayStart() {

            }

            @Override
            public void onAmpsVideoPlayEnd() {

            }
        });
        interstitialAd.loadAd();
    }
}